//
//  XBCollectionViewCell.m
//  寻宝之旅
//
//  Created by LyuBook on 16/4/10.
//  Copyright © 2016年 lvdingze. All rights reserved.
//

#import "XBCollectionViewCell.h"
#import "XBAuction.h"
#import "UIImageView+WebCache.h"
#import "XBAuctionGroup.h"
@interface XBCollectionViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *viewCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UIButton *praiseCountBtn;
@end

@implementation XBCollectionViewCell


- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        self.titleLabel.layer.cornerRadius = 10;
        [self.titleLabel.layer masksToBounds];
    }
    return self;
}
-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        self.titleLabel.layer.cornerRadius = 10;
    }
    return self;
}

-(void)setAuction:(XBAuction *)auction{
    
    if(auction){
        _auction = auction;
        self.titleLabel.text = auction.title;
        self.viewCountLabel.text = [NSString stringWithFormat:@"%@人围观",auction.viewCount];
        self.priceLabel.text = [NSString stringWithFormat:@"￥%@",auction.price];
        [self.praiseCountBtn setTitle:auction.praiseCount forState:UIControlStateNormal];
        [self.iconView sd_setImageWithURL:[NSURL URLWithString:auction.imgUrl]];
    }
}

-(void)setAuctionGroup:(XBAuctionGroup *)auctionGroup{

    _auctionGroup = auctionGroup;
     [self.iconView sd_setImageWithURL:[NSURL URLWithString:auctionGroup.imgUrl]];
}

@end
